package com.example.leetdemo.finash;

import lombok.Data;


public class Solution1816 {

    public String truncateSentence(String s, int k) {
        int size = 0;
        for (int i = 0; i < s.length(); i++) {
            if (' ' == s.charAt(i)) {
                size++;
            }
            if (size == k) {
                return s.substring(0, i);
            }
        }
        return s;
    }

    public static void main(String[] args) {
        System.err.println("12345".substring(0, 4));
    }
}
